# Maintainer: Alexey Pavlov <alexpux@gmail.com>
# Contributor: Renato Silva <br.renatosilva@gmail.com>
# Contributor: Eduard Braun <eduard.braun2@gmx.de>

_realname=gtkspell
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=2.0.16
pkgrel=7
pkgdesc="Provides word-processor-style highlighting and replacement of misspelled words in a GtkTextView widget (mingw-w64)"
arch=('any')
url="https://gtkspell.sourceforge.io/"
license=(GPL2)
makedepends=("gtk-doc"
            "${MINGW_PACKAGE_PREFIX}-gcc"
            "${MINGW_PACKAGE_PREFIX}-pkg-config"
            "intltool")
depends=("${MINGW_PACKAGE_PREFIX}-gtk2"
         "${MINGW_PACKAGE_PREFIX}-enchant")
options=(!libtool strip staticlibs)
source=(https://gtkspell.sourceforge.io/download/${_realname}-${pkgver}.tar.gz
        gtkspell-no-undefined.patch
        001-localedir-relocation.patch
        enchant-2.diff)
sha256sums=('8fc7dc560167b2cb7193e76aca625a152dc19b0ebf49816b78539cbb90d80d02'
            'cb6978c914d5a20544cad2ba6b3a58096daadc420d21f99797949c7f3a02e57b'
            '1b4c6400c19eef9e36cb85fcb6c9a97a49d474bdd24ba4e8bfb29f3bacefa868'
            '52e693590161bc285ec46a2beece802f47c7ede65ec0b72ffa224ab0db176bad')

prepare() {
  cd ${_realname}-${pkgver}
  patch -p1 -i ${srcdir}/gtkspell-no-undefined.patch
  patch -p1 -i ${srcdir}/001-localedir-relocation.patch
  patch -p1 -i ${srcdir}/enchant-2.diff

  gtkdocize
  WANT_AUTOMAKE=latest autoreconf -fi
}

build() {
  mkdir -p "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"
  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --enable-shared \
    --disable-static

  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="${pkgdir}" install
  install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
}
